/*
 * @Author: 2112778581 2112778581@qq.com
 * @Date: 2023-10-16 13:42:57
 * @LastEditors: fengshan525 2735332396@qq.com
 * @LastEditTime: 2025-09-21 15:02:32
 * @FilePath: \pra\libs\db\src\models\list-detail.model.ts
 * @Description: 列表详情模型
 */

import { ApiProperty } from '@nestjs/swagger';
import { modelOptions, prop } from '@typegoose/typegoose';
import { IsNotEmpty, Allow, IsOptional } from 'class-validator';

@modelOptions({
  // 自动为每个属性添加时间戳
  schemaOptions: {
    timestamps: true,
  },
})
export class ListDetail {
  @ApiProperty({ description: '标题' })
  @IsNotEmpty({ message: '标题不能为空' })
  @prop()
  title: string;

  @ApiProperty({ description: '副标题' })
  @IsOptional()
  @prop()
  subtitle?: string;

  @ApiProperty({ description: '描述' })
  @IsOptional()
  @prop()
  description: string;

  @ApiProperty({ description: '链接名称' })
  @IsNotEmpty({ message: '链接名称不能为空' })
  @prop()
  linkName: string;

  @ApiProperty({ description: '真实链接' })
  @IsNotEmpty({ message: '真实链接不能为空' })
  @prop()
  link: string;

  @ApiProperty({ description: '发布时间' })
  @IsOptional()
  @prop()
  publishTime?: Date;

  @ApiProperty({ description: '作者' })
  @IsOptional()
  @prop()
  author?: string;

  @ApiProperty({ description: 'SEO关键词' })
  @IsOptional()
  @prop()
  seoKey?: string;

  @ApiProperty({ description: 'SEO描述' })
  @IsOptional()
  @prop()
  seoDesc?: string;

  @ApiProperty({ description: '浏览量' })
  @IsOptional()
  @prop({ default: 0 })
  viewCount?: number;

  @ApiProperty({ description: '内容' })
  @IsNotEmpty({ message: '内容不能为空' })
  @prop()
  content: string;

  @ApiProperty({ description: '所属分类id' })
  @IsNotEmpty({ message: '所属分类不能为空' })
  @prop()
  categoryId: string;

  @ApiProperty({ description: '所属分类名称' })
  @IsOptional()
  @prop()
  categoryName?: string;

  @ApiProperty({ description: '所属模型id' })
  @IsOptional()
  @prop()
  modelId?: string;

  @ApiProperty({ description: '所属模型名称' })
  @IsOptional()
  @prop()
  modelName?: string;

  @ApiProperty({ description: '主图(多张,至少一张)' })
  @IsOptional()
  @prop()
  mainImages: string[];

  @ApiProperty({ description: '缩略图（多张,至少一张)' })
  @IsOptional()
  @prop()
  thumbnailImages: string[];

  @ApiProperty({ description: '绑定模块id' })
  @IsOptional()
  @prop()
  moduleId?: string;

  @ApiProperty({ description: '绑定模块名称' })
  @IsOptional()
  @prop()
  moduleName?: string;

  @ApiProperty({ description: '伪静态id' })
  @IsOptional()
  @prop()
  staticId?: string;

  @ApiProperty({ description: '价格' })
  @IsOptional()
  @prop()
  price?: number;

  @ApiProperty({ description: '参数列表' })
  @IsOptional()
  @prop()
  parameterList?: { name: string; value: string }[];

  @ApiProperty({ description: '是否发布' })
  @IsOptional()
  @prop({ default: false })
  isPublished?: boolean;

  @ApiProperty({ description: '是否推荐' })
  @IsOptional()
  @prop({ default: false })
  isRecommend?: boolean;

  @ApiProperty({ description: '标签(数组)' })
  @IsOptional()
  @prop()
  tags?: { name: string }[];

  @ApiProperty({ description: '型号' })
  @IsOptional()
  @prop()
  modelType?: string;

  @ApiProperty({ description: '参数' })
  @IsOptional()
  @prop()
  parameters?: { name: string; value: string }[];

  // 是否置顶
  @ApiProperty({ description: '是否置顶' })
  @IsOptional()
  @prop({ default: false })
  isTop?: boolean;

  // 排序
  @ApiProperty({ description: '排序' })
  @IsOptional()
  @prop({ default: 0 })
  sort?: number;

  @ApiProperty({ description: '是否相关推荐' })
  @IsOptional()
  @prop({ default: false })
  isRelatedRecommend?: boolean;

  @Allow()
  _id: string;

  @Allow()
  createdAt: string;

  @Allow()
  updatedAt: string;

  @Allow()
  __v: string;
}